<template>
  <div>
    <p>
      Child: {{ money }}
      <button @click="updateMoney(3)">花钱</button>
    </p>
    <p>age: {{ age }}</p>
  </div>
</template>

<script>
import { inject } from 'vue'
export default {
  setup() {
    // !#2 通过 inject 注入 money
    const money = inject('money')
    // !#4 拿到修改数据的方法
    const updateMoney = inject('updateMoney')
    const age = inject('age')
    return { money, age, updateMoney }
  }
}
</script>

<style lang="scss" scoped>

</style>